package com.yxkj.syh.app.huarong.activities.user.setting;

import android.content.Intent;
import android.os.Bundle;

import androidx.lifecycle.Observer;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.syh.app.basic.base.BaseActivity;
import com.syh.app.basic.utils.ActivityManager;
import com.yxkj.syh.app.huarong.BR;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.activities.account.login.LoginActivity;
import com.yxkj.syh.app.huarong.constants.ArouterPath;
import com.yxkj.syh.app.huarong.databinding.ActivitySettingBinding;

/**
 * 设置
 */
@Route(path = ArouterPath.SETTING_ACTIVITY)
public class SettingActivity extends BaseActivity<ActivitySettingBinding, SettingVM> {

    @Override
    protected int getContentLayout() {
        return R.layout.activity_setting;
    }

    @Override
    protected int getViewModelId() {
        return BR.settingVM;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mVDBinding.titleView.setLeftOnClickListener(v -> {
            finish();
        });


        mVDBinding.llNotice.setOnClickListener(v -> {
            ARouter.getInstance().build(ArouterPath.NOTICE_LIST_ACTIVITY).navigation();
        });
    }

    @Override
    protected void initObservers() {
        super.initObservers();
        mViewModel.mldLogin.observe(this, aBoolean -> {
            ActivityManager.getInstance().finishAllActivity();
            Intent intent = new Intent(SettingActivity.this, LoginActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
        });
    }
}
